#include<stdio.h>
void add(float* a,float* b,float* c)
{
	*c = *a + *b;
}
void subtract(float* a , float* b , float* c)
{
	*c = *a-*b;
}
void multiply(float *a , float* b , float*c)
{
	*c = *a * *b;
}
void divide(float* a , float* b , float*c)
{
	*c= *a / *b;
}
int main()
{
 	float X,Y,Z;
  	float *pX,*pY,*pZ;
	char oper;
	pX = &X;
	pY = &Y;
	pZ = &Z;
	printf("My Calculator\nInput P as operation to end session\n");
	do
	{
        printf("calculation:");
		scanf("%g%c%g",pX,&oper,pY);
		switch (oper)
		{
            case '+':
            add(pX,pY,pZ);
			printf("Result =%4.2f\n",Z);
			break;
			case '-':
			subtract(pX,pY,pZ);
			printf("Result =%4.2f\n",Z);
			break;
			case '*':
			multiply(pX,pY,pZ);
			printf("Result =%4.2f\n",Z);
			break;
			case '/':
			divide(pX,pY,pZ);
			printf("Result =%4.2f\n",Z);
			break;
			case 'P':
			break;
			default:
			printf("Invalid operation!\n");
			break;
		}
	} while (oper!='P');
	
	return 0;
}
